package util;

import com.csvreader.CsvWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import jr.LiquidacionJR;

/**
 *
 * @author The_Rub
 */
public class CSVExporter {

  public static void GenerarCSV(ArrayList<LiquidacionJR> liquidaciones, String file) throws IOException {

    CsvWriter out = new CsvWriter(new FileWriter(file, false), ',');

    out.write("Período de la liquidación");
    out.write("Total del período");
    out.write("Médico");
    out.write("Especialidad");
    out.write("Matrícula");
    out.write("Monto de la consulta");
    out.write("Total mensual del médico");
    out.write("Fecha");
    out.write("Hora");
    out.write("Paciente");
    out.write("Plan");
    out.write("N° de Afiliado");
    out.endRecord();

    for (LiquidacionJR l : liquidaciones) {
      out.write(l.getLiquidacion());
      out.write(l.getTotalLiquidacion());
      out.write(l.getMedico());
      out.write(l.getEspecialidad());
      out.write(l.getMatricula());
      out.write(l.getMontoConsulta());
      out.write(l.getTotalPorMedico());
      out.write(l.getFecha());
      out.write(l.getHora());
      out.write(l.getPaciente());
      out.write(l.getPlanObraSocial());
      out.write(l.getNumeroAfiliado());
      out.endRecord();
    }

    out.close();
  }

}
